package com.jsnj33.pdaproject.ui;

import android.app.Activity;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.jsnj33.pdaproject.R;
import com.jsnj33.pdaproject.adapter.MainAdapter;
import com.jsnj33.pdaproject.utils.MainUtils;

import java.io.Serializable;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        RecyclerView recyclerView = findViewById(R.id.recyclerview);
        recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
        MainAdapter adapter = new MainAdapter(this, null) {
            @Override
            protected void clickItem(String accounts) {

                Intent intent = new Intent();
                switch (accounts) {
                    case "暂估单":
                        intent.setClass(MainActivity.this, ZanguActivity.class);
                        intent.putExtra("title", accounts);
                        intent.putExtra("list", (Serializable) (MainUtils.getProvisional()));
                        startActivity(intent);
                        break;
                    case "进货单":
                        intent.setClass(MainActivity.this, ZanguActivity.class);
                        intent.putExtra("title", accounts);
                        intent.putExtra("list", (Serializable) (MainUtils.getInorder()));
                        startActivity(intent);
                        break;
                    case "出库单":
                        intent.setClass(MainActivity.this, ZanguActivity.class);
                        intent.putExtra("title", accounts);
                        intent.putExtra("list", (Serializable) (MainUtils.getOutStock()));
                        startActivity(intent);
                        break;
                    case "销货单":
                        intent.setClass(MainActivity.this, ZanguActivity.class);
                        intent.putExtra("title", accounts);
                        intent.putExtra("list", (Serializable) (MainUtils.getSalesorder()));
                        startActivity(intent);
                        break;

                    case "调整单":
                        intent.setClass(MainActivity.this, AdjustmentActivity.class);
                        intent.putExtra("title", accounts);
                        intent.putExtra("list", (Serializable) (MainUtils.getAdjustmentSheet()));
                        startActivity(intent);
                        break;
                    case "盘点单":
                        intent.setClass(MainActivity.this, InventoryActivity.class);
                        intent.putExtra("title", accounts);
                        intent.putExtra("list", (Serializable) (MainUtils.getCheckList()));
                        startActivity(intent);
                        break;
                    case "调拨单":
                        intent.setClass(MainActivity.this, AllocationActivity.class);
                        intent.putExtra("title", accounts);
                        intent.putExtra("list", (Serializable) (MainUtils.getRQN()));
                        startActivity(intent);
                        break;

                    case "GZ-领料单":
                        intent.setClass(MainActivity.this, PickingActivity.class);
                        intent.putExtra("title", accounts);
                        intent.putExtra("list", (Serializable) (MainUtils.getlldzld()));
                        startActivity(intent);
                        break;
                    case "退料单":
                        intent.setClass(MainActivity.this, PickingActivity.class);
                        intent.putExtra("title", accounts);
                        intent.putExtra("list", (Serializable) (MainUtils.getReturnSheet()));
                        startActivity(intent);
                        break;
                    case "补料单":
                        intent.setClass(MainActivity.this, PickingActivity.class);
                        intent.putExtra("title", accounts);
                        intent.putExtra("list", (Serializable) (MainUtils.getSupplySheet()));
                        startActivity(intent);
                        break;
                    case "GZ-缴货单":
                        intent.setClass(MainActivity.this, FormActivity.class);
                        intent.putExtra("title", accounts);
                        intent.putExtra("list", (Serializable) (MainUtils.getPayingBills()));
                        startActivity(intent);
                        break;
                    case "GZ-报工单":
                        intent.setClass(MainActivity.this, JobReportActivity.class);
                        intent.putExtra("title", accounts);
                        intent.putExtra("list", (Serializable) (MainUtils.getJobReportBills()));
                        startActivity(intent);
                        break;
                    case "工序查询":
                        intent.setClass(MainActivity.this, ToollookActivity.class);
                        intent.putExtra("title", accounts);
                        intent.putExtra("list", (Serializable) (MainUtils.getTookLookBills()));
                        startActivity(intent);
                        break;
                    case "送检单":
                        intent.setClass(MainActivity.this, InspectionActivity.class);
                        intent.putExtra("title", accounts);
                        intent.putExtra("list", (Serializable) (MainUtils.getMaterialRequisition()));
                        startActivity(intent);
                        break;
                    case "原料调拨单":
                        intent.setClass(MainActivity.this, TransferOrderActivity.class);
                        intent.putExtra("title", accounts);
                        intent.putExtra("list", (Serializable) (MainUtils.getTransfer()));
                        startActivity(intent);
                        break;
                    case "箱码绑定":
                        intent.setClass(MainActivity.this, BindActivity.class);
                        intent.putExtra("state", "bind");
                        startActivity(intent);
                        break;
                    case "箱码查询":
                        intent.setClass(MainActivity.this, BindActivity.class);
                        intent.putExtra("state", "look");
                        startActivity(intent);
                        break;
                    case "Z数据查询":
                        intent.setClass(MainActivity.this, RecordActivity.class);
                        intent.putExtra("title", "Z数据查询");
                        startActivity(intent);
                        break;
                    case "进库":
                        intent.setClass(MainActivity.this, InActivity.class);
                        intent.putExtra("title", "进库");
                        intent.putExtra("oper_flag", "in");
                        startActivity(intent);
                        break;
                    case "出库":
                        intent.setClass(MainActivity.this, InActivity.class);
                        intent.putExtra("title", "出库");
                        intent.putExtra("oper_flag", "out");
                        startActivity(intent);
                        break;
                    case "进库记录":
                        intent.setClass(MainActivity.this, InOutRecordActivity.class);
                        intent.putExtra("title", "进库记录");
                        intent.putExtra("oper_flag", "in");
                        startActivity(intent);
                        break;
                    case "出库记录":
                        intent.setClass(MainActivity.this, InOutRecordActivity.class);
                        intent.putExtra("title", "出库记录");
                        intent.putExtra("oper_flag", "out");
                        startActivity(intent);
                        break;
                    case "GZ-调整单":
                        intent.setClass(MainActivity.this, GZ_ChangeListActivity.class);
                        intent.putExtra("title", accounts);
                        intent.putExtra("list", (Serializable) (MainUtils.getLibraryChange()));
                        startActivity(intent);
                        break;
                    case "GZ-库存调减单":
                        intent.setClass(MainActivity.this, GZ_LibraryChangeActivity.class);
                        intent.putExtra("title", accounts);
                        intent.putExtra("state", 0);
                        startActivity(intent);
                        break;
                    case "GZ-库存调增单":
                        intent.setClass(MainActivity.this, GZ_LibraryChangeActivity.class);
                        intent.putExtra("title", accounts);
                        intent.putExtra("state", 1);
                        startActivity(intent);
                        break;
                    default:
                        break;
                }
            }
        };
        recyclerView.setAdapter(adapter);

        adapter.setList(MainUtils.getData());
    }
}